#ifndef	CHESSTYPE_H
#define CHESSTYPE_H

#include "d3dUtil.h"

/////////////////////enum type///////////////////////////////////////

enum CastleState
{
	Enable,
	Disable,
	Impossible
};

enum CastleMove
{
	NoCastle,
	WhiteKingSide,
	WhiteQueenSide,
	BlackKingSide,
	BlackQueenSide
};


//////////////////////class and struct//////////////////////////////////////
class BoardCoord
{
public:
	short		x,y;

	BoardCoord(){}
	BoardCoord(short _x,short _y)
		:x(_x)
		,y(_y)
	{}
	~BoardCoord(){}

	friend inline std::ostream& operator<<(std::ostream& os,const BoardCoord& coord)
	{
		return os;
	}
};

class ChessManMoveDir
{
//a chessman can move in one direction go iMaxStep step
public:
	short x,y;
	short iMaxStep;

	ChessManMoveDir()
		:x(0)
		,y(0)
		,iMaxStep(0)
	{}

	ChessManMoveDir(int _x,int _y,int _step)
		:x(_x)
		,y(_y)
		,iMaxStep(_step)
	{}
	~ChessManMoveDir(){}
};

class ChessManMoveInfo
{
public:
	//x,y is the direction in the x axis and y axis
	short x,y;
	short step;
	//the coordinate 0<=x,y<8
	//if you want use the 12x12 coordinate ,you need do some convert
	BoardCoord chessManCoord;

	friend inline std::ostream& operator<<(std::ostream& os,const ChessManMoveInfo& info)
	{
		os<<"begin coordinate : ("<<info.chessManCoord.x<<" , "<<info.chessManCoord.y<<") "<<std::endl;
		os<<"end coordinate : ("<<info.chessManCoord.x+info.x*info.step<<" , "<<info.chessManCoord.y+info.y*info.step<<") ";
		return os;
	}

	ChessManMoveInfo()
		:x(-1)
		,y(-1)
		,step(-1)
	{}
	~ChessManMoveInfo(){}
};

class ChessBoardUpdateInfo
{
public:
	bool bGameOver;
	bool bHasCapture;
	bool bCanEnPassant;
	bool bPawnPromotion;
	short captureChessManType;

	CastleMove		castleMove;

	CastleState		castleBlackKingSide;
	CastleState		castleBlackQueenSide;
	CastleState		castleWhiteKingSide;
	CastleState		castleWhiteQueenSide;

	//the coordinate 0<=x,y<8
	//if you want use the 12x12 coordinate ,you need do some convert
	BoardCoord captureCoord;
	BoardCoord EnPassantCoord;
	ChessManMoveInfo moveInfo;
};


///////////////////const value////////////////////////////////////////////

//chessman
const int	MaxNumChessMan = 7;
const short Empty = 0;
const short Pawn = 1;
const short Rook = 2;
const short Knight = 3;
const short Bishop = 4;
const short Queen = 5;
const short King = 6;

const short Invaild = 10;

//player
const int White = 1;
const int Black = -1;

//board
const short ChessBoardSize = 12;
const short RowBeginIndex = 2;
const short ColBeginIndex = 2;

const std::string ChessManNameTab[]={"Empty","Pawn","Rook","Knight","Bishop","Queen","King"};

#endif